<?php namespace Admin\Controller;
use Hdphp\Controller\Controller;

class TypeAttrController extends CommonController{
	private $model;

	public function __construct(){
		parent::__construct();
		$this->model = new \Common\Model\TypeAttr;
	}

	public function index(){
		$tid = Q('get.tid','0','intval');
		View::with('tid',$tid);
		$data = $this->model->getInfo($tid);
		View::with('data',$data);
		View::make();
	}

	public function add(){
		$tid = Q('get.tid','0','intval');
		$aid = Q('get.aid','0','intval');
		if(IS_POST){
			if($this->model->addData(Q('get.tid','0','intval'),Q('post.'))){
				View::success('添加成功',U('index',array('aid'=>$aid,'tid'=>$tid)));
			}
			View::error($this->model->getError());
		}
		View::make();
	}

	public function edit(){
		$tid = Q('get.tid','0','intval');
		$aid = Q('get.aid','0','intval');
		if(IS_POST){
			if($this->model->editData($aid)){
				View::success('修改成功',U('index',array('aid'=>$aid,'tid'=>$tid)));
			}
			View::error($this->model->getError());
		}
		$oldData = $this->model->where("aid={$aid}")->find();
		View::with('oldData',$oldData);
		View::make();
	}

	public function del(){
		$this->model->delData(Q('get.aid','0','intval'));
		View::success('删除成功');
	}
}


 ?>